#ifndef __QUAD2D_H__
#define __QUAD2D_H__

#include "vector2d.h"

template <class T>
class quad2d
{
public:
	vector2d<T> Top;
	vector2d<T> Down;

public:
	quad2d()																											{}
	quad2d(T nx, T ny, T nx2, T ny2) : Top(vector2d<T>(nx,ny)), Down(vector2d<T>(nx2,ny2))								{}
	quad2d(const quad2d<T>& other) : Top(other.Top), Down(other.Down)													{}
	virtual ~quad2d()																									{}

	virtual bool IsPointInside(T x, T y)
	{
		bool XInside(false);
		bool YInside(false);

		if (Top.X < Down.X)
			XInside = (x >= Top.X && x <= Down.X);
		else
			XInside = (x >= Down.X && x <= Top.X);

		if (XInside)
			if (Top.Y < Down.Y)
				YInside = (y >= Top.Y && y <= Down.Y);
			else
				YInside = (y >= Down.Y && y <= Top.Y);

		return XInside && YInside;
	}

	virtual bool IsPointInside(vector2d<T> Point)	{	return IsPointInside(Point.X,Point.Y);	}
};

typedef quad2d<vPos> quad2dvpos;
typedef quad2d<f32> quad2df32;
typedef quad2d<u32> quad2du32;
typedef quad2d<s32> quad2ds32;
typedef quad2d<u16> quad2du16;
typedef quad2d<s16> quad2ds16;
typedef quad2d<u8> quad2du8;
typedef quad2d<s8> quad2ds8;

#endif
